package person.bing.fbcloud.auth.handle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: mengfanbing
 * @date: 2019/12/31 14:55
 */
@Slf4j
@Component
//public class SuccessEventHandler implements ApplicationListener<AuthenticationSuccessEvent>{
//public class SuccessEventHandler implements AuthenticationSuccessHandler {
public class SuccessEventHandler extends SavedRequestAwareAuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        super.onAuthenticationSuccess(request,response,authentication);
    }
   /* @Override
    public void onApplicationEvent(AuthenticationSuccessEvent event) {
        Authentication authentication = (Authentication)event.getSource();
        if (CollUtil.isNotEmpty(authentication.getAuthorities())){
            log.info("用户：{} 登陆成功",authentication.getPrincipal());
        }
    }*/

}
